<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root"></div>

    <script>
        Vue.config.productionTip = false;
        // student组件
        const student = Vue.extend({
            name:"student",
            template:
               `<div>
                    <h1>学生名字：{{studentName}}</h1>
                    <h1>学生年龄：{{age}}</h1>
                </div>`,
            data(){
                return {
                    studentName:'张三',
                    age:18,
                }
            },
        });

        // school组件
        const school = Vue.extend({
            name:"school",
            template:
               `<div>
                   <h1>学校名称：{{schoolName}}</h1>
                   <h1>学校地址：{{address}}</h1>
                   <hr>
                   <student></student>
                </div>`,
            data(){
                return {
                    schoolName:'尚硅谷',
                    address:'北京',
                }
            },
            components:{
                student
            }
        });
       
        // 定义hello组件
        const hello = {
            name:"hello1",
            template:
               `<div>
                   <h1>你好，尚硅谷！</h1>
                   <hr>
                </div>`,
        };

        // 定义app组件（它包含除vue之外的所有组件）
        const app = Vue.extend({
            template:
               `<div>
                    <hello></hello>
                    <school></school>
                </div>`,
            data(){
                return {
                    schoolName:'尚硅谷',
                    address:'北京',
                }
            },
            components:{
                school, hello
            }
        });

        let vm = new Vue({
            template:
            `<div>
                <app></app>
            </div>`,
            el: '#root',
            // 注册组件
            components:{
                app
            }
        });
    </script>
</body>
</html>